package com.yunhe.java.day06;

public class Student {
        String name;
        int age;char sex;double weight;boolean  single;String phone;
        static int  power;static Student[] students;
        static {
            power = 5;students = new Student[17];}
        {  power += 2;}
        public  Student(){}  //定义构造器时，先写一个无参空构造器
        public Student(String name){
            this(name,'男',"123456");}
        public Student(String name, char sex, String phone){
            this(name,0,sex,0.0,false,phone);}
        public Student(String name, int age, char sex, double weight, boolean single, String phone) {
            this.name = name ;this.age = age;this.sex = sex;this.weight = weight;this.phone=phone;}
        public void powerCase1(){
            if(power >= 100) { System.out.println("再接再厉");}}
        public boolean powerCase2(){
            if(power <= 5) { System.out.println("能量不足5！");}
            return power <= 5;}
        public void looking(){
            powerCase1();power += 2;
            System.out.println(this.name + "看书，能量 + 2");}
        public void practicing(){
           powerCase1();power += 2;System.out.println(this.name + "做练习，能量 + 2");}
        public void playGames(){
            if(!powerCase2()) { power -= 4;System.out.println(this.name + "打游戏，能量 - 4");}}
        public void  sleeping() { if(!powerCase2()) {
            power -= 2;System.out.println(this.name + "睡觉，能量 - 2");}}
        public static void  showPower(){ System.out.println("能量为：" + power);}
        public static void sayAllName(){
            System.out.print("所有学员：" );
            for(Student p : students){
                if(null != p) {
                    System.out.print( p.name + ",");
                }
            }
        }
    }


